<template>
    <a-modal
        destroyOnClose
        :title="title"
        :width="width"
        :visible="visible"
        :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
        @ok="handleOk"
        @cancel="handleCancel"
    >
        <HonorForm ref="HonorForm" id="HonorForm" :browseMode="browseMode" :editable="editable" :editableFiexd="editableFiexd" :dataId="dataId" v-model="formData"></HonorForm>
        <div slot="footer">
            <a-button key="cancel" @click="handleCancel">
                取消
            </a-button>
            <!-- <a-button v-if="browseMode" key="print" v-print="'#HonorForm'">
                导出pdf
            </a-button> -->
           <a-button type="primary" @click="handleOk">
                确定
            </a-button>
        </div>
    </a-modal>
</template>

<script>
import HonorForm from './HonorForm'
export default {
    name:'HonorModal',
    components:{
        HonorForm
    },
    data(){
        return {
            title:'',
            width:1000,
            visible: false,
            disableSubmit: false,
            canDismiss:false,
            editable:true,
            showBuildTime:false,
            formData:{},
            editableFiexd:{},
            dataId:'',
            successTxt:'',
            browseMode:false
        }
    },
    methods:{
        add (record,editableFiexd) {
            this.visible = true
            this.$nextTick(()=>{
                this.editableFiexd = editableFiexd
                this.$refs.HonorForm.add(record)
            })
        },
        apply(data,editableFiexd){
            this.visible = true
            this.$nextTick(()=>{
                this.editableFiexd = editableFiexd
                this.$refs.HonorForm.add(Object.assign({},data,{
                    workflowModel:{
                        operation: "start"
                    }
                }))
            })
        },
        edit (record,editableFiexd) {
            this.visible = true
            this.$nextTick(()=>{
                this.editableFiexd = editableFiexd
                this.$refs.HonorForm.edit(record)
            })
        },
        review (record) {
            this.title = '查看'
            this.visible=true
            this.editable = false
            this.disableSubmit = true
            this.browseMode = true
            this.$nextTick(()=>{
                this.$refs.HonorForm.open(record)
            })
        },
        close () {
            this.$emit('close');
            this.title = ''
            this.editable = true
            this.formData = {}
            this.editableFiexd = {}
            this.disableSubmit = false
            this.visible = false
            this.showBuildTime = false
            this.canDismiss = false,
            this.browseMode = false
        },
        handleOk () {
            this.$refs.HonorForm.submitForm().then(res=>{
                this.$emit('ok');
                this.visible = false;
            })
        },
        handleCancel () {
            this.close()
        }
    }
}
</script>

<style>

</style>